package com.cn.aop.annotation;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class LogAspect {
	@Pointcut("execution(* com.cn.aop.annotation.AP.work(..)) || execution(* com.cn.aop.annotation.AP.work2(..))")
    private void anyMethod(){}
	/*@Before("anyMethod()")
	public String doBefore(JoinPoint p){
		Apoint a = (Apoint) p.getTarget();
		System.out.println("my test before,param is"+a.str);
		return "ccc";
	}*/
	@Around("anyMethod()")
	public int doArround(ProceedingJoinPoint pjp){
		System.out.println("my test start");
		try {
			Object [] os = new Object[1];
			//改变了参数
			os[0] = new Integer(321);
			pjp.proceed(os);
		} catch (Throwable e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println("my test over");
		return 123;
	}
}
